<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <link rel="stylesheet" th:href="@{/adminlte/layui/css/layui.css}"  media="all"/>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<!--<div class="layui-btn-group demoTable">
    <button class="layui-btn" data-type="getCheckData">获取选中行数据</button>
    <button class="layui-btn" data-type="getCheckLength">获取选中数目</button>
    <button class="layui-btn" data-type="isAll">验证是否全选</button>
</div>-->
<!--<h3 style="margin-top: -10px; margin-left:-10px;">检测入库</h3>-->
<div class="demoTable">
    所在地区：
    <div class="layui-inline" style="width: 220px">
        <select name="localSearch" lay-verify=""  style="width: 210px" onchange="supplierNameSearch()">
            <option value="" ></option>
        </select>
    </div>
    <div class="layui-inline" style="margin-left: -15px">供应商名称：</div>
    <div class="layui-inline" style="width: 220px;">
        <select name="supplierNameSearch" lay-verify=""  style="width: 210px" onchange="goodsType()">
            <option value="" ></option>
        </select>
    </div>
    物料类别：
    <div class="layui-inline" style="width: 220px">
        <select name="goodsTypeSearch" lay-verify=""  style="width: 210px" onchange="goodsName()">
            <option value="" ></option>
        </select>
    </div>
    物料名称：
    <div class="layui-inline" style="width: 220px">
        <select name="goodsNameSearch" lay-verify=""  style="width: 210px" onchange="specifications()">
            <option value="" ></option>
        </select>
    </div><br/>
    物料规格：
    <div class="layui-inline" style="width: 220px">
        <select name="specificationsSearch" lay-verify=""  style="width: 210px" >
            <option value="" ></option>
        </select>
    </div>
    起始日期：
    <div class="layui-inline" style="width: 220px">
        <input class="layui-input"  id="startDateSearch" autocomplete="off" style="width: 200px;height: 25px"/>
    </div>
    截止日期：
    <div class="layui-inline" style="width: 220px">
        <input class="layui-input"  id="endDateSearch" autocomplete="off" style="width: 200px;height: 25px"/>
    </div>
    <button class="layui-btn layui-btn-sm" data-type="reload">查询</button>
</div>
<script type="text/html" id="toolbarDemos">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="addIndustry"  >添加</button>
        <button class="layui-btn layui-btn-sm" lay-event="updateIndustry"  >修改</button>
        <button class="layui-btn layui-btn-sm" lay-event="deleteIndustry"  >删除</button>
    </div>
</script>
<table class="layui-table" lay-data="{totalRow:true,url:'/goodsInStock/goodsInStockDate', page:true, id:'idTestIndustry',toolbar:'#toolbarDemos',defaultToolbar:['filter', 'print','exports'] }" lay-filter="demoIndustry">
    <thead>
    <tr>
        <th lay-data="{type:'checkbox', fixed: 'left'}" rowspan="2"></th>
        <th lay-data="{field:'goodsType', width:150}" rowspan="2">订单号</th>
        <th lay-data="{field:'goodsType', width:150}" rowspan="2">产品名称</th>
        <th lay-data="{field:'goodsName',width:150}" rowspan="2">规格</th>
        <th lay-data="{align:'center'}" colspan="5">阀门信息</th>
        <th lay-data="{align:'center'}" colspan="5">控制主板信息</th>
        <th lay-data="{align:'center'}" colspan="10">通讯主板信息</th>
        <th lay-data="{align:'center'}" colspan="6">485主板信息</th>
        <th lay-data="{field:'goodsName',width:150}" rowspan="2">操作人</th>
        <th lay-data="{field:'goodsName',width:150}" rowspan="2">操作时间</th>
        <th lay-data="{field:'goodsName',width:150}" rowspan="2">备注</th>
        <th lay-data="{align:'center'}" colspan="3">工艺</th>
    </tr>
    <tr>
        <th lay-data="{field:'status', width:150 }">供应商名称</th>
        <th lay-data="{field:'goodsNums', width:150,totalRow:true}">阀门名称</th>
        <th lay-data="{field:'supplierName', width:150}">阀门编号</th>
        <th lay-data="{field:'pipelineNumber', width:150}">规格</th>
        <th lay-data="{field:'operators', width:150}">进气方向</th>
        <th lay-data="{field:'status', width:150 }">供应商名称</th>
        <th lay-data="{field:'goodsNums', width:150,totalRow:true}">控制主板名称</th>
        <th lay-data="{field:'supplierName', width:150}">控制主板编号</th>
        <th lay-data="{field:'pipelineNumber', width:150}">规格</th>
        <th lay-data="{field:'operators', width:150}">生产日期</th>
        <th lay-data="{field:'iMSI', width:150}">IMSI号</th>
        <th lay-data="{field:'iMEI', width:150}">IMEI号</th>
        <th lay-data="{field:'iCCID', width:150}">ICCID号</th>
        <th lay-data="{field:'operator', width:150}">操作人</th>
        <th lay-data="{field:'operatorTime', width:150}">操作时间</th>
        <th lay-data="{field:'cardNums', width:150}">卡号</th>
        <th lay-data="{field:'iMSI', width:150}">IMSI号</th>
        <th lay-data="{field:'iMEI', width:150}">IMEI号</th>
        <th lay-data="{field:'iCCID', width:150}">ICCID号</th>
        <th lay-data="{field:'operator', width:150}">操作人</th>
        <th lay-data="{field:'operator', width:150}">操作人</th>
        <th lay-data="{field:'operatorTime', width:150}">操作时间</th>
        <th lay-data="{field:'cardNums', width:150}">卡号</th>
        <th lay-data="{field:'iMSI', width:150}">IMSI号</th>
        <th lay-data="{field:'iMEI', width:150}">IMEI号</th>
        <th lay-data="{field:'iCCID', width:150}">ICCID号</th>
        <th lay-data="{field:'operator', width:150}">操作人</th>
        <th lay-data="{field:'operatorTime', width:150}">操作时间</th>
        <th lay-data="{field:'remarks', width:150}">备注</th>
    </tr>
    </thead>
</table>

<script th:src="@{/adminlte/layui/layui.js}" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.on('checkbox(demoIndustry)', function(obj){
            console.log(obj)
        });
        //监听工具条
        table.on('tool(demoIndustry)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                /*layer.alert('编辑行：<br/>'+ JSON.stringify(data))*/

            }
        });
        //监听头工具栏事件
        table.on('toolbar(demoIndustry)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id)
                ,data = checkStatus.data//获取选中的数据
                ,deList=[1];
            data.forEach(function (n,i) {
                deList.push(n.id)
            });
            deList.push(2);
            switch(obj.event){
                case 'addIndustry':
                    layer.open({
                        type:1,
                        title:'添加',
                        btnAlign: 'c',
                        area: ['500px', '600px'],
                        content: $("#add-mainIndustry"),
                        btn:['保存','取消'],
                        yes:function(index,layero){
                            $.ajax({
                                //几个参数需要注意一下
                                type: "POST",//方法类型
                                dataType: "json",//预期服务器返回的数据类型
                                url: "" ,//url
                                data: {},
                                success: function (result) {
                                    console.log(result);//打印服务端返回的数据(调试用)
                                    if (result.success >0) {
                                        alert("操作成功");
                                        table.reload('idTestIndustry');
                                    }else{
                                        alert("系统错误");
                                    }
                                },
                                error : function() {
                                    alert("异常！");
                                }
                            });

                            layer.close(index);
                        },
                        btn2:function (index) {
                            layer.close(index);
                        }
                    })
                    break;
                case 'updateIndustry':
                    if(data.length === 0){
                        layer.msg('请选择一行');
                    } else if(data.length > 1){
                        layer.msg('只能同时编辑一个');
                    } else {
                        var id =checkStatus.data[0].id;
                        layer.confirm('确定？',{btn: ['确定', '取消'], title: "提示"},function(index){
                            $.ajax({
                                //几个参数需要注意一下
                                type: "POST",//方法类型
                                dataType: "json",//预期服务器返回的数据类型
                                url: "" ,//url
                                data: {deList:JSON.stringify(deList)},
                                success: function (result) {
                                    if (result.success>0) {
                                        alert("操作成功");
                                        table.reload('idTestIndustry')
                                    }else{
                                        alert("系统错误");
                                    }
                                },
                                error : function() {
                                    alert("异常！");
                                }
                            });
                            layer.close(index);
                        });
                    }
                    break;
                case 'deleteIndustry':
                    if(data.length === 0){
                        layer.msg('请选择一行');
                    } else {
                        layer.confirm('确定删除',{btn: ['确定', '取消'], title: "提示"},function(index){
                            $.ajax({
                                //几个参数需要注意一下
                                type: "POST",//方法类型
                                dataType: "json",//预期服务器返回的数据类型
                                url: "" ,//url
                                data: {deList:JSON.stringify(deList)},
                                success: function (result) {
                                    if (result.success>0) {
                                        alert("操作成功");
                                        table.reload('idTestIndustry')
                                    }else{
                                        alert("系统错误");
                                    }
                                },
                                error : function() {
                                    alert("异常！");
                                }
                            });
                            layer.close(index);
                        });
                    }
                    break;
            }
        });
        var $ = layui.$, active = {
            /*     getCheckData: function(){ //获取选中数据
                     var checkStatus = table.checkStatus('idTest')
                         ,data = checkStatus.data;
                     layer.alert(JSON.stringify(data));
                 }
                 ,getCheckLength: function(){ //获取选中数目
                     var checkStatus = table.checkStatus('idTest')
                         ,data = checkStatus.data;
                     layer.msg('选中了：'+ data.length + ' 个');
                 }
                 ,isAll: function(){ //验证是否全选
                     var checkStatus = table.checkStatus('idTest');
                     layer.msg(checkStatus.isAll ? '全选': '未全选')
                 }
                 ,*/
            reload:function () {
                var local = $("[name='localSearch'] option:selected").text();
                var supplierName = $("[name='supplierNameSearch'] option:selected").text();
                var goodsType = $("[name='goodsTypeSearch'] option:selected").text();
                var goodsName = $("[name='goodsNameSearch'] option:selected").text();
                var specifications = $("[name='specificationsSearch'] option:selected").text();
                var startDate = $("#startDateSearch").val();
                var endDate = $("#endDateSearch").val();
                table.reload('idTestIndustry',{
                    url:'',
                    where:{local:local,supplierName:supplierName,goodsType:goodsType,goodsName:goodsName,specifications:specifications,startDate:startDate,endDate:endDate,page:1,limit:10}  ,
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                })

            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#startDateSearch' //指定元素
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#endDateSearch' //指定元素
            ,type: 'datetime'
        });
    });
</script>

</body>
</html>